package com.bentley.kotlindemo.ui.kits.home

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bentley.kotlindemo.R

class MyAdapter : RecyclerView.Adapter<MyHolder>() {

    var list: List<String> = ArrayList<String>()
    var click: OnItemClick? = null

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder {

        val view = LayoutInflater.from(parent!!.context).inflate(R.layout.item_test, parent, false)
        val holder = MyHolder(view, click!!)
        return holder
    }

    fun add(list: List<String>) {
        this.list = list

    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: MyHolder, position: Int) {

        holder.textView.setText(list.get(position))

    }

    fun setOnItemClick(click: OnItemClick) {
        this.click = click;
    }


}